	.module led.c
	.area text(rom, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\led.c
	.dbfunc e bsp_led_gpio_init _bsp_led_gpio_init fV
	.even
_bsp_led_gpio_init::
	.dbline -1
	.dbline 21
; 
; #include "hw_config.h"
; #include "led.h"
; 
; #if 0
; // define led port and pin for core module
; bsp_port_group_type led_core_group[ledCoreMax]=
; {
; 	{(u16*)&DDRE, (u16*)&PORTE, (u16*)&PINE, PE3 }
; };
; 
; // define led port and pin for bottom board
; bsp_port_group_type led_bottom_group[ledBottomMax]=
; {
; 	{(u16*)&DDRC, (u16*)&PORTC, (u16*)&PINC, PC1 },
; 	{(u16*)&DDRE, (u16*)&PORTE, (u16*)&PINE, PE2 }
; };
; #endif
; 
; void bsp_led_gpio_init(void)
; {
	.dbline 28
; 	// Output
; 	//sbi(*led_core_group[ledUserCore].ddr, led_core_group[ledUserCore].pin_no);
; 
; 	//sbi(*led_core_group[ledUserBottom1].ddr, led_core_group[ledUserBottom1].pin_no);
; 	//sbi(*led_core_group[ledUserBottom2].ddr, led_core_group[ledUserBottom2].pin_no);
; 
; 	sbi(USER_CORE_LED_DDR, USER_CORE_LED_PIN_NO);
	sbi 0x2,3
	.dbline 30
; 
; 	sbi(USER_BOTTOM_LED1_DDR, USER_BOTTOM_LED1_PIN_NO);
	sbi 0x14,1
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e bsp_led_core_on _bsp_led_core_on fV
;            led -> R16
	.even
_bsp_led_core_on::
	.dbline -1
	.dbline 37
; #ifdef M128_MIDDLE_HW_VER1		
; 	sbi(USER_BOTTOM_LED2_DDR, USER_BOTTOM_LED2_PIN_NO);	
; #endif
; }
; 
; void bsp_led_core_on(bsp_led_core_type led)
; {
	.dbline 38
; 	if( led >= ledCoreMax )
	cpi R16,1
	brlo L7
X0:
	.dbline 39
; 		return;
	xjmp L6
L7:
	.dbline 42
; 
; 	//sbi(*led_core_group[led].port, led_core_group[led].pin_no);
; 	sbi(USER_CORE_LED_PORT, USER_CORE_LED_PIN_NO);
	sbi 0x3,3
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbsym r led 16 c
	.dbend
	.dbfunc e bsp_led_core_off _bsp_led_core_off fV
;            led -> R16
	.even
_bsp_led_core_off::
	.dbline -1
	.dbline 46
; }
; 
; void bsp_led_core_off(bsp_led_core_type led)
; {
	.dbline 47
; 	if( led >= ledCoreMax )
	cpi R16,1
	brlo L10
X1:
	.dbline 48
; 		return;
	xjmp L9
L10:
	.dbline 51
; 
; 	// cbi(*led_core_group[led].port, led_core_group[led].pin_no);
; 	cbi(USER_CORE_LED_PORT, USER_CORE_LED_PIN_NO);
	cbi 0x3,3
	.dbline -2
L9:
	.dbline 0 ; func end
	ret
	.dbsym r led 16 c
	.dbend
	.dbfunc e bsp_led_core_toggle _bsp_led_core_toggle fV
;           pins -> R20,R21
;            led -> R16
	.even
_bsp_led_core_toggle::
	st -y,R20
	st -y,R21
	.dbline -1
	.dbline 55
; }
; 
; void bsp_led_core_toggle(bsp_led_core_type led)
; {
	.dbline 58
; 	u16 pins;
; 
; 	if( led >= ledCoreMax )
	cpi R16,1
	brlo L13
X2:
	.dbline 59
; 		return;
	xjmp L12
L13:
	.dbline 73
; 
; 	/*
; 	pins = (u16)(inp((u16)*led_core_group[ledUserCore].pin, led_core_group[ledUserCore].pin_no));
; 	if ((pins & led_core_group[led].pin_no) == 0)
; 	{
; 		sbi(*led_core_group[led].port, led_core_group[led].pin_no);
; 	}
; 	else
; 	{
; 		cbi(*led_core_group[led].port, led_core_group[led].pin_no);
; 	}	
; 	*/
; 
; 	pins = inp(USER_CORE_LED_PIN, USER_CORE_LED_PIN_NO);
	in R20,0x1
	clr R21
	andi R20,8
	andi R21,0
	.dbline 74
; 	if ((pins & 1<<USER_CORE_LED_PIN_NO) == 0)
	sbrc R20,3
	rjmp L15
X3:
	.dbline 75
; 	{
	.dbline 76
; 		sbi(USER_CORE_LED_PORT, USER_CORE_LED_PIN_NO);
	sbi 0x3,3
	.dbline 77
; 	}
	xjmp L16
L15:
	.dbline 79
; 	else
; 	{
	.dbline 80
; 		cbi(USER_CORE_LED_PORT, USER_CORE_LED_PIN_NO);
	cbi 0x3,3
	.dbline 81
; 	}
L16:
	.dbline -2
L12:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r pins 20 i
	.dbsym r led 16 c
	.dbend
	.dbfunc e bsp_led_bottom_on _bsp_led_bottom_on fV
;            led -> R16
	.even
_bsp_led_bottom_on::
	.dbline -1
	.dbline 85
; }
; 
; void bsp_led_bottom_on(bsp_led_bottom_type led)
; {
	.dbline 86
; 	if( led >= ledBottomMax )
	cpi R16,1
	brlo L18
X4:
	.dbline 87
; 		return;
	xjmp L17
L18:
	.dbline 91
; 
; 	//cbi(*led_bottom_group[led].port, led_bottom_group[led].pin_no);
; 
; 	if( led == ledUserBottom1 )
	tst R16
	brne L20
X5:
	.dbline 92
; 		sbi(USER_BOTTOM_LED1_PORT, USER_BOTTOM_LED1_PIN_NO);
	sbi 0x15,1
L20:
	.dbline -2
L17:
	.dbline 0 ; func end
	ret
	.dbsym r led 16 c
	.dbend
	.dbfunc e bsp_led_bottom_off _bsp_led_bottom_off fV
;            led -> R16
	.even
_bsp_led_bottom_off::
	.dbline -1
	.dbline 100
; #ifdef M128_MIDDLE_HW_VER1	
; 	else if( led == ledUserBottom2 )
; 		sbi(USER_BOTTOM_LED2_PORT, USER_BOTTOM_LED2_PIN_NO);
; #endif	
; }
; 
; void bsp_led_bottom_off(bsp_led_bottom_type led)
; {
	.dbline 101
; 	if( led >= ledBottomMax )
	cpi R16,1
	brlo L23
X6:
	.dbline 102
; 		return;
	xjmp L22
L23:
	.dbline 106
; 
; 	//sbi(*led_bottom_group[led].port, led_bottom_group[led].pin_no);
; 
; 	if( led == ledUserBottom1 )
	tst R16
	brne L25
X7:
	.dbline 107
; 		cbi(USER_BOTTOM_LED1_PORT, USER_BOTTOM_LED1_PIN_NO);
	cbi 0x15,1
L25:
	.dbline -2
L22:
	.dbline 0 ; func end
	ret
	.dbsym r led 16 c
	.dbend
	.dbfunc e bsp_led_bottom_toggle _bsp_led_bottom_toggle fV
;           pins -> R20,R21
;            led -> R16
	.even
_bsp_led_bottom_toggle::
	st -y,R20
	st -y,R21
	.dbline -1
	.dbline 115
; #ifdef M128_MIDDLE_HW_VER1	
; 	else if( led == ledUserBottom2 )
; 		cbi(USER_BOTTOM_LED2_PORT, USER_BOTTOM_LED2_PIN_NO);
; #endif	
; }
; 
; void bsp_led_bottom_toggle(bsp_led_bottom_type led)
; {
	.dbline 118
; 	u16 pins;
; 
; 	if( led >= ledBottomMax )
	cpi R16,1
	brlo L28
X8:
	.dbline 119
; 		return;
	xjmp L27
L28:
	.dbline 121
; 
; 	if( led == ledUserBottom1 )
	tst R16
	brne L30
X9:
	.dbline 122
; 	{
	.dbline 123
; 		pins = inp(USER_BOTTOM_LED1_PIN, USER_BOTTOM_LED1_PIN_NO);
	in R20,0x13
	clr R21
	andi R20,2
	andi R21,0
	.dbline 124
; 		if ((pins & 1<<USER_BOTTOM_LED1_PIN_NO) == 0)
	sbrc R20,1
	rjmp L32
X10:
	.dbline 125
; 		{
	.dbline 126
; 			sbi(USER_BOTTOM_LED1_PORT, USER_BOTTOM_LED1_PIN_NO);
	sbi 0x15,1
	.dbline 127
; 		}
	xjmp L33
L32:
	.dbline 129
; 		else
; 		{
	.dbline 130
; 			cbi(USER_BOTTOM_LED1_PORT, USER_BOTTOM_LED1_PIN_NO);
	cbi 0x15,1
	.dbline 131
; 		}
L33:
	.dbline 132
; 	}
L30:
	.dbline -2
L27:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r pins 20 i
	.dbsym r led 16 c
	.dbend
; }
